package com.ybkj.o2o.mc.common;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import org.apache.commons.lang.time.DateFormatUtils;

import java.io.IOException;
import java.util.Date;

/**
 * Created by shine on 16/6/27.
 */
public class DateTimeMinuteField extends JsonSerializer<Date> {

  @Override
  public void serialize(Date date, JsonGenerator jsonGenerator,
                        SerializerProvider serializerProvider) throws IOException {

    String value = DateFormatUtils.format(date, "yyyy-MM-dd HH:mm");
    jsonGenerator.writeString(value);
  }
}
